package com.woniuxy.buyer.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.buyer.entity.Product;
import com.woniuxy.buyer.mapper.ProductMapper;
import com.woniuxy.buyer.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品服务实现
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<Product> getOnlineProducts() {
        return productMapper.selectOnlineProducts();
    }

    @Override
    public List<Product> getProductsByCategory(Long categoryId) {
        return productMapper.selectProductsByCategory(categoryId);
    }

    @Override
    public Product getProductDetail(Long productId) {
        Product product = this.getById(productId);
        if (product != null && "ONLINE".equals(product.getStatus())) {
            // 这里可以添加更多的商品详情信息，比如商家信息等
            return product;
        }
        return null;
    }
}
